import Vue from "vue";
import VueRouter from "vue-router";
import MSite from "../views/MSite/MSite.vue";
import Order from "../views/Order/Order.vue";
import Profile from "../views/Profile/Profile.vue";
import Search from "../views/Search/Search.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/msite",
  },
  {
    path: "/msite",
    name: "MSite",
    component: MSite,
    meta: {
      title: "点外卖",
      isShowBottomBar: true,
    },
  },
  {
    path: "/order",
    name: "Order",
    component: Order,
    meta: {
      title: "订单",
      isShowBottomBar: true,
    },
  },
  {
    path: "/search",
    name: "Search",
    component: Search,
    meta: {
      title: "搜索",
      isShowBottomBar: true,
    },
  },

  {
    path: "/profile",
    name: "Profile",
    component: Profile,
    meta: {
      title: "个人信息",
      isShowBottomBar: true,
    },
  },
  {
    path: "/shopBusiness/:id/:shopName",
    name: "ShopBusiness",
    props: true,
    component: () => import("../views/ShopBusiness/ShopBusiness.vue"),
    meta: {
      title: "商品",
    },
  },
  {
    path: "/checkout",
    name: "Checkout",
    component: () => import("../views/Checkout/Checkout.vue"),
    meta: {
      title: "结算",
    },
  },
  {
    path: "/categoryDetail/:title",
    props: true,
    name: "CategoryDetail",
    component: () => import("../views/CategoryDetail/CategoryDetail.vue"),
    meta: {
      title: "分类",
    },
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("../views/Login/Login.vue"),
    meta: {
      title: "登录",
    },
  },
  {
    path: "/about",
    name: "About",
    component: () => import("../views/About/About.vue"),
    meta: {
      title: "关于我们",
    },
  },
  {
    path: "/userAgreement",
    name: "userAgreement",
    component: () => import("../views/UserAgreement/UserAgreement.vue"),
    meta: {
      title: "用户协议与隐私",
    },
  },
  {
    path: "*",
    name: "NotFound",
    component: () => import("../views/NotFound/NotFound.vue"),
    meta: {
      title: "页面走丢失了",
    },
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
router.afterEach((to, from) => {
  document.title = to.meta.title;
});
